package com.tubeonfire.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.tubeonfire.util.JavaCacheHandle;

public class HomeController extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");		
		try {
			request.setAttribute("listCategory", JavaCacheHandle.getCategory());
			request.setAttribute("listBanner",
					JavaCacheHandle.getMostViewAllTime());
			request.setAttribute("listChannel", JavaCacheHandle.getChannels());
			request.setAttribute("listMostView",
					JavaCacheHandle.getMostViewToday());
			request.setAttribute("listMostPopular",
					JavaCacheHandle.getPopular());
			request.setAttribute("listMostRecent", JavaCacheHandle.getRecent());
			request.setAttribute("listPl", JavaCacheHandle.getPl());
			request.getRequestDispatcher("/home.jsp")
					.forward(request, response);
		} catch (ServletException e) {
			e.printStackTrace();
		}
	}

}
